
function validate(form){
	if (form.userR.value == null || form.userR.value==""){
		error=1;
		$('errorUser').update('This field must not be empty');
		}
	else
		$('errorUser').update();
	if (form.passwordR.value == null || form.userR.value==""){
		error=1;
		$('errorPassword').update('This field must not be empty');
		}
	else if (form.passwordR.value != form.password2R.value){
		error=1;
		$('errorPassword').update('Wrong password');
		}
	else
		$('errorPassword').update();
	if (form.nameR.value == null || form.userR.value==""){
		error=1;
		$('errorName').update('This field must not be empty');
		}
	else
		$('errorName').update();
		
	if ((form.dayR.value == "") || (form.monthR.value == "") || (form.yearR.value == "")){
		error = 1;
		$('errorDate').update('This field must not be empty');
        }
	else if (!(Object.isNumber(form.dayR.value) && Object.isNumber(form.monthR.value) && Object.isNumber(form.yearR.value))){
		error = 1;
		$('errorDate').update('Wrong date');
        }
	else{
		var day = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		if (form.monthR.value == 2 && (form.yearR.value%400 == 0 || (form.yearR.value%4 == 0 && form.yearR.value%100 != 0)))
			day[1]++;
		if (form.monthR.value < 1 || form.monthR.value > 12){
			error = 1;
			$('errorDate').update('Wrong date');
			}
		else if (form.dayR.value < 1 || form.dayR.value > day[form.monthR.value-1]){
			error = 1;
			$('errorDate').update('Wrong date');
			}
		else{
			dateR = new Date(form.yearR.value, form.monthR.value, form.dayR.value);
			today = new Date();
			if(dateR > today){
				error = 1;
				$('errorDate').update('Wrong date');
				}
			else
				$('errorDate').update();
		}
	}
	
	if((form.emailR.value == null) || (form.emailR.value == "")){
		error == 1;
		$('errorEmail').update('This field must not be empty');
		}
	else{
		apos=form.emailR.value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if ((apos < 1) || (dotpos-apos < 2)){
			error = 1;
			$('errorEmail').update('Wrong email');
			}
		else
			$('errorEmail').update('');
	}
	
    if (error)
		return false;
    else
		return true;
}

